package singleton.myself.threadlocal;

/**
 * Created by Tom.
 */
public class ThreadLocalSingleton {
  /*  private static final ThreadLocal<ThreadLocalSingleton> threadLocaLInstance =
            new ThreadLocal<ThreadLocalSingleton>(){
                @Override
                protected ThreadLocalSingleton initialValue() {
                    return new ThreadLocalSingleton();
                }
            };

    private ThreadLocalSingleton(){}

    public static ThreadLocalSingleton getInstance(){
        return threadLocaLInstance.get();
    }*/

    public static final  ThreadLocal<ThreadLocalSingleton> threadLocal =new ThreadLocal<ThreadLocalSingleton>(){
        @Override
        protected ThreadLocalSingleton initialValue() {
            return new ThreadLocalSingleton();
        }
    };
    private ThreadLocalSingleton(){

    }
    public static ThreadLocalSingleton getInstance(){
        return threadLocal.get();
    }
}
